<?php
/**
 * Created by PhpStorm.
 * User: Sojo
 * Date: 2017/6/20
 * Time: 19:34
 */
namespace App\Api\Service\Test\Controllers;

use Framework\BaseClass\Api\Controller;
use App\Api\Service\Test\Models\Contacts;
use Dingo\Api\Http\Response;

class ContactsController extends Controller
{
    /**
     * 获取通讯录数据
     * @author Sojo
     * @return mixed
     */
    public function getContactsData()
    {
//        try {
//            $userInfo = app('token')->checkToken();
//            $userId = $userInfo->id;
//        } catch (\DebugError $e) {
//            $userId = 0;
//        }

        // @author lulingfeng 2017.9.5 验证角色 start---
//        if (!empty($userInfo)) {
//            $role = new Role();
//            $role->checkRole($userInfo->id, $userInfo->company_id);
//        }
        // @author lulingfeng 2017.9.5 验证角色 end-----

        $userId     = 2;
        $contacts = new Contacts();
        $contactsData = $contacts->getContactsData($userId);

        return json_decode($contactsData, true);
    }

    /**
     * 下载通讯录头像
     * @author Sojo
     * @return mixed
     */
    public function downloadAvatar()
    {
        return response()->download(public_path('avatar.zip'));
    }
}